package com.mauth.web.service.impl;

import com.mauth.common.entity.auth.UserRole;
import com.mauth.common.entity.user.User;
import com.mauth.web.repository.UserRepository;
import com.mauth.web.repository.UserRoleRepository;
import com.mauth.web.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Optional;

@Service
public class UserServiceImpl implements UserService {
    @Resource
    private UserRoleRepository userRoleRepository;

    @Resource
    private UserRepository userRepository;

    @Override
    public UserRole getUserAuth(Integer userId) {
        Optional<UserRole> userRole = userRoleRepository.findById(1);
        return userRole.orElse(null);
    }

    @Override
    public User getUser(Integer userId) {
        return userRepository.findById(userId).orElse(null);
    }

    @Override
    public User getUser(String userSeq) {
        return userRepository.findByUserSeq(userSeq).orElse(null);
    }

    @Override
    public User getUserByName(String userName) {
        return userRepository.findByUserName(userName).orElse(null);
    }
}
